﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MISAPP.Classify.DataAccess;
using System.Data;
using MISAPP.MISInterface;

namespace MISAPP.Classify.Service
{
    public class Service_CreditCardCount
    {
        public string[] SheetName = { "有效卡", "流通卡", "百分比"
                                        ,"ThisLast","LastYear" };
        protected DA_CreditCardCount da = null;
        protected DA_CreditCardCount DA
        {
            get
            {
                if (da == null)
                {
                    da = new DA_CreditCardCount();
                }
                return da;
            }
        }

        public bool Insert(object[,] p_cartypes, object[,] p_circulates
            ,object[,] p_effectives, string p_ymd,bool p_check)
        {
            int newY = p_ymd.Length.Equals(5) 
                ? Convert.ToInt16(p_ymd.Substring(0,3)) + 1911
                : Convert.ToInt16(p_ymd.Substring(0,2)) + 1911;
            p_ymd = string.Format("{0}-{1}-01", newY.ToString()
                , p_ymd.Substring(p_ymd.Length.Equals(5)?3:2));
            if(p_check == true)
            {
                Check(p_ymd);            
            }
            
            return DA.Insert(p_cartypes, p_circulates, p_effectives, p_ymd);
        }

        public bool Insert(object[,] p_cartypes, object[,] p_circulates
            , object[,] p_effectives, string p_ymd)
        {
            return Insert(p_cartypes, p_circulates, p_effectives, p_ymd
                , true);
        }

        public void Check(string p_ymd)
        {
            DA.Check(p_ymd);
        }

        public DataSet GetSummaryData()
        {            
            DataSet ds = DA.GetSummaryData(SheetName);
            return ds;
        }
    }
}
